package com.xiexie.seckill.vo;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class RespBean {

    private Integer code;

    private String message;

    private Object data;

    public RespBean() {}

    public static RespBean error(RespBeanEnum respBeanEnum) {
        RespBean respBean = new RespBean();
        respBean.setCode(respBeanEnum.getCode());
        respBean.setMessage(respBeanEnum.getMessage());
        return respBean;
    }

    public static RespBean error(Object data) {
        RespBean respBean = new RespBean();
        respBean.setCode(RespBeanEnum.ERROR.getCode());
        respBean.setMessage(RespBeanEnum.ERROR.getMessage());
        respBean.setData(data);
        return respBean;
    }

    public static RespBean success() {
        RespBean respBean = new RespBean();
        respBean.setCode(RespBeanEnum.SUCCESS.getCode());
        respBean.setMessage(RespBeanEnum.SUCCESS.getMessage());
        return respBean;
    }

    public static RespBean success(Object data) {
        RespBean respBean = new RespBean();
        respBean.setCode(RespBeanEnum.SUCCESS.getCode());
        respBean.setMessage(RespBeanEnum.SUCCESS.getMessage());
        respBean.setData(data);
        return respBean;
    }


}
